<?php

// Prevent individual file access
if(!defined('DIR_BASE')) exit;

/**
 * Display a view
 */
class View{
	
	/**
	 * Contains the current instance
	 */
	private static $instance;
	
	/**
	 * Prevent duplicates of the view
	 * Return $instance;
	 */
	public static function getInstance(){
		if (self::$instance == null)
			self::$instance = new self();
		return self::$instance;
	}
	private function __construct(){}
	
	/**
	 * Export a json-array
	 */
	public function display($result, $success = true){
		echo json_encode(
			array(
				'result'  => $result,
				'success' => $success
			)
		);
	}
	
	/**
	 * @see display
	 */
	public function error($errormessage){
		$this->display($errormessage, false);
	}
}

?>